# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html

import re
import time

class SinaStockPipeline(object):
    def process_item(self, item, spider):
        today=time.strftime('%Y-%m-%d',time.localtime())
        fileName='stock_' + today + '.txt'

        with open(fileName,'a',encoding='utf-8',errors='ignore') as f:
            stock = item['stock']
            stock_name = item['stock_name']
            ipo_price = item['ipo_price']
            ipo_number = item['ipo_number']
            money = item['money']
            ipo_start = item['ipo_start']
            ipo_end = item['ipo_end']
            for i in (stock,stock_name,ipo_price,ipo_number,money,ipo_start,ipo_end):
                f.write(str(i) + '\n')
            return item
